#include "MQHelper.hpp"
#include <cassert>
using namespace std;

/**
 *
 */
int duplicateVertex (MQObject mq_obj, int old_vertex)
{
    MQPoint p = mq_obj->GetVertex (old_vertex);
    int new_vertex = mq_obj->AddVertex (p);

    mq_obj->CopyVertexAttribute (new_vertex, mq_obj, old_vertex);

    return new_vertex;
}


/**
 *
 */
int duplicateFace   (MQObject mq_obj, int old_face, int new_face_vertex_count, int* new_face_vertex_indices)
{
    assert (new_face_vertex_count == mq_obj->GetFacePointCount(old_face));

    int new_face = mq_obj->AddFace (new_face_vertex_count, new_face_vertex_indices);

    MQCoordinate uvarray[4];
    mq_obj->GetFaceCoordinateArray (old_face, uvarray);
    mq_obj->SetFaceCoordinateArray (new_face, uvarray);

    for (int v = 0; v < new_face_vertex_count; v++) {
        DWORD color = mq_obj->GetFaceVertexColor (old_face, v);
        mq_obj->SetFaceVertexColor (new_face, v, color);
    }

    int material = mq_obj->GetFaceMaterial (old_face);
    mq_obj->SetFaceMaterial (new_face, material);

    return new_face;
}

